<template>
  <div class="login-container">
    <div id="wxlogin-container" class="wxlogin-container"></div>
    <div class="login-disc">手机端与PC端可以同步信息</div>
  </div>
</template>

<script>
import { returnUrlToRedirectUri } from "@/utils/helpers/wx-helper";
export default {
  name: "WxLogin",
  data() {
    return {
      redirect: undefined
    };
  },
  created() {
    const redirect = this.$route.query && this.$route.query.redirect;
    this.redirect = redirect;
  },
  mounted() {
    var origin = window.location.origin;
    // var origin = 'http://teacher.jielong.csproj.com';
    var returnUrl = origin + "/auth-redirect";
    if (this.redirect) {
      returnUrl = origin + "/auth-redirect?redirect=" + returnUrlToRedirectUri(this.redirect);
    }
    const redirect_uri = encodeURIComponent(returnUrl);

    /* eslint-disable */
    var obj = new WxLogin({
      self_redirect: false,
      id: "wxlogin-container",
      appid: "wxcd9c9ac1c155dda2",
      scope: "snsapi_login",
      redirect_uri: redirect_uri,
      state: "Csproj_WxComponent_Bind",
      style: "white",
      href: ""
    });
  },
  methods: {}
};
</script>

<style lang="scss" scoped>
$bg: #2d3a4b;

.login-container {
  min-height: 100%;
  background-color: $bg;
  width: 100%;
  overflow: hidden;

  .wxlogin-container {
    position: relative;
    width: 370px;
    max-width: 100%;
    padding: 160px 35px 0;
    margin: 0 auto;
    overflow: hidden;
  }
}
  .login-disc{
    text-align: center;
    color: #ffffff;
  }
</style>
